package com.zqh.irmadscore.controller;


import com.zqh.irmadscore.model.entity.MonitoringNeeds;
import com.zqh.irmadscore.service.NeedsService;
import com.zqh.irmadscore.utils.resultUtils.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequiredArgsConstructor
@RequestMapping("/tracts")
@Tag(name = "监测需求")
public class NeedsController {

    private final NeedsService needsService;

    @GetMapping("/test")
    public String test() {
        return "test";
    }

    @Operation(summary = "获取全部监测需求")
    @GetMapping("/getNeeds")
    public Result<List<MonitoringNeeds>> getNeeds() {

        List<MonitoringNeeds> list = needsService.list();

        return Result.ok(list);

    }

    @Operation(summary = "根据id获取监测需求")
    @GetMapping("/getNeedsById")
    public Result<MonitoringNeeds> getNeedsById(Integer id) {

        MonitoringNeeds monitoringNeeds = needsService.getById(id);

        return Result.ok(monitoringNeeds);
    }

    @Operation(summary = "根据id删除监测需求")
    @GetMapping("/deleteNeedsById")
    public Result<MonitoringNeeds> deleteNeedsById(Integer id) {
        needsService.removeById(id);
        return Result.ok();
    }

    @Operation(summary = "添加监测需求")
    @GetMapping("/addNeeds")
    public Result<MonitoringNeeds> addNeeds(MonitoringNeeds monitoringNeeds) {

        needsService.save(monitoringNeeds);
        return Result.ok();
    }





}
